<div [@routerTransition]>
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    <span>{{("Editions")}}</span>
                </h3>
                <span class="m-section__sub">
                    {{"EditionsHeaderInfo" | localize}}
                </span>
            </div>
            <div class="col text-right mt-3 mt-md-0">
                <button *ngIf="'Pages.Editions.Create' | permission" class="btn btn-primary" (click)="createEdition()"><i class="fa fa-plus"></i> {{"CreateNewEdition" | localize}}</button>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <div class="row align-items-center">
                    <!--<Primeng-TurboTable-Start>-->
                    <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                        <p-table #dataTable
                                 (onLazyLoad)="getEditions()"
                                 [value]="primengTableHelper.records"
                                 rows="{{primengTableHelper.defaultRecordsCountPerPage}}"
                                 [paginator]="false"
                                 [lazy]="true"
                                 [responsive]="primengTableHelper.isResponsive">
                            <ng-template pTemplate="header">
                                <tr>
                                    <th style="width: 130px;"
                                        [hidden]="!isGrantedAny('Pages.Editions.Edit', 'Pages.Editions.Delete')">
                                        {{'Actions' | localize}}
                                    </th>
                                    <th>
                                        {{'EditionName' | localize}}
                                    </th>
                                    <th>
                                        {{'Price' | localize}}
                                    </th>
                                    <th>
                                        {{'IsTrialActive' | localize}}
                                    </th>
                                    <th>
                                        {{'WaitingDayAfterExpire' | localize}}
                                    </th>
                                    <th>
                                        {{'ExpiringEdition' | localize}}
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-record="$implicit">
                                <tr>
                                    <td style="width: 130px;text-align:center">
                                        <div class="btn-group dropdown" dropdown>
                                            <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                <i class="fa fa-cog"></i><span class="caret"></span> {{"Actions" | localize}}
                                            </button>
                                            <ul class="dropdown-menu" *dropdownMenu>
                                                <li>
                                                    <a href="javascript:;" *ngIf="'Pages.Editions.Edit' | permission"
                                                       (click)="editEditionModal.show(record.id)">{{'Edit' | localize}}</a>
                                                </li>

                                                <li>
                                                    <a href="javascript:;" *ngIf="'Pages.Editions.Delete' | permission"
                                                       (click)="deleteEdition(record)">{{'Delete' | localize}}</a>
                                                </li>

                                                <li>
                                                    <a href="javascript:;" *ngIf="'Pages.Editions.MoveTenantsToAnotherEdition' | permission"
                                                       (click)="moveTenantsToAnotherEditionModal.show(record.id)">{{'MoveTenantsToAnotherEdition' | localize}}</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                    <td>
                                        <span class="ui-column-title">{{'EditionName' | localize}}</span>
                                        {{record.displayName}}
                                    </td>
                                    <td>
                                        <span class="ui-column-title">{{'Price' | localize}}</span>
                                        <span *ngIf="record.monthlyPrice || record.annualPrice">
                                            $ {{record.monthlyPrice}} {{"Monthly" | localize }} / $ {{record.annualPrice}} {{"Annual" | localize }}
                                        </span>
                                        <span *ngIf="!record.monthlyPrice && !record.annualPrice">
                                            {{"Free" | localize}}
                                        </span>
                                    </td>
                                    <td>
                                        <span class="ui-column-title">{{'IsTrialActive' | localize}}</span>
                                        <span *ngIf="record.trialDayCount">
                                            {{"Yes" | localize}}, {{record.trialDayCount}} {{"Days" | localize}}
                                        </span>
                                        <span *ngIf="!record.trialDayCount">
                                            {{"No" | localize}}
                                        </span>
                                    </td>
                                    <td>
                                        <span class="ui-column-title">{{'WaitingDayAfterExpire' | localize}}</span>
                                        {{record.waitingDayAfterExpire}}
                                    </td>
                                    <td>
                                        <span class="ui-column-title">{{'ExpiringEdition' | localize}}</span>
                                        {{record.expiringEditionDisplayName}}
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                            {{'NoData' | localize}}
                        </div>
                        <div class="ui-table-footer">
                        </div>
                    </div>
                    <!--<Primeng-TurboTable-End>-->
                </div>
            </div>
        </div>
    </div>

    <createEditionModal #createEditionModal (modalSave)="getEditions()"></createEditionModal>
    <editEditionModal #editEditionModal (modalSave)="getEditions()"></editEditionModal>
    <moveTenantsToAnotherEditionModal #moveTenantsToAnotherEditionModal></moveTenantsToAnotherEditionModal>
</div>
